package com.zzyl.mapper;

import com.zzyl.entity.Resource;
import com.zzyl.vo.MenuVo;
import com.zzyl.vo.ResourceVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ResourceMapper {
    List<ResourceVo> list(Resource resource);

    @Select("select * from sys_resource where resource_no = #{parentResourceNo}")
    Resource selectByResourceNo(String parentResourceNo);

    @Select("select * from sys_resource where parent_resource_no = #{parentResourceNo}")
    List<Resource> selectByParentResourceNo(String parentResourceNo);

    @Insert("insert into sys_resource (resource_no, parent_resource_no, resource_name, resource_type, request_path, label, data_state, sort_no, icon, create_time, update_time, remark, create_by, update_by) " +
            "VALUES (#{resourceNo}, #{parentResourceNo},#{resourceName},#{resourceType},#{requestPath},#{label},#{dataState},#{sortNo},#{icon},#{createTime},#{updateTime},#{remark},#{createBy},#{updateBy})")
    void insert(Resource resource);

    void update(Resource resource);

    @Select("select * from sys_resource where parent_resource_no like concat('%',#{resourceNo},'%') ")
    List<Resource> getResourceNoByParent(String resourceNo);


    List<String> getButtonResourceById(Long userId);

    List<MenuVo> selectMenuByUserId(Long userId);
}
